<template>
  <div id="app-container">
    <!-- 头部 -->
    <mt-header fixed title="HmmMall">
      <mt-button icon="back" slot="left" @click="goBack" v-if="showGoBackVisible">返回</mt-button>
    </mt-header>

    <!-- 路由占位符 -->
    <!-- 过度动画 -->
    <transition>
      <router-view></router-view>
    </transition>

    <!-- tabbar区域 -->
    <mt-tabbar />
  </div>
</template>

<script>
import MtTabbar from "./Tabbar.vue";
export default {
  components: {
    MtTabbar
  },
  created() {
    this.$route.path === "/home"
      ? (this.showGoBackVisible = false)
      : (this.showGoBackVisible = true);
  },
  data() {
    return {
      showGoBackVisible: true
    };
  },

  watch: {
    "$route.path"(newValue, oldValue) {
      if (newValue === "/home") {
        this.showGoBackVisible = false;
      } else {
        this.showGoBackVisible = true;
      }
    }
  },
  methods: {
    goBack() {
      this.$router.go(-1);
    }
  }
};
</script>

<style scoped>
#app-container {
  padding-top: 40px;
  padding-bottom: 50px;
  overflow: hidden;
}

.v-enter {
  opacity: 0;
  transform: translateX(100%);
}
.v-leave-to {
  display: none;
  transform: translateX(-100%);
}
.v-enter-active,
.v-leave-active {
  transition: all 0.4s ease;
}
.mint-header {
  z-index: 99;
}
</style>